//
//  DJMyFeedBackHuifuVC.m
//  daojiVideo
//
//  Created by tikeios_002 on 2024/6/7.
//

#import "DJMyFeedBackHuifuVC.h"
#import "DJFeedbackListCell.h"
#import "QYDetailViewController.h"
#import "QYShopInfoViewController.h"
#import "CSJADLoading.h"

@interface DJMyFeedBackHuifuVC ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) NSMutableArray *listArr;
@property (nonatomic, assign) NSInteger page;
@property (weak, nonatomic) IBOutlet UITableView *huiTable;
@property (strong,nonatomic) PublicView * nullView;
@property (weak, nonatomic) IBOutlet UIView *adView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *adHeight;

@end

@implementation DJMyFeedBackHuifuVC
- (NSMutableArray *)showTextViewToKey1:(NSString *)keyString{
    NSMutableArray *showTextViewArrTo1 = [NSMutableArray new];
    for (int i = 0; [showTextViewArrTo1 count] < 5; i++) {
        int  RandomNumber = arc4random() % 30;
        if(![showTextViewArrTo1 containsObject:[NSNumber numberWithInt:RandomNumber]]){
            [showTextViewArrTo1 addObject:[NSNumber numberWithInt:RandomNumber]];
        }
    }
    return showTextViewArrTo1;
}
- (NSInteger)showTextViewToTime1:(NSString *)time{
    NSDateFormatter *showTextViewFaTo1 = [[NSDateFormatter alloc] init];
    [showTextViewFaTo1 setDateFormat:@"yyyy-MM-dd"];
    return [[showTextViewFaTo1 dateFromString:time] timeIntervalSince1970];
}
- (NSMutableArray *)listArr{
    if(_listArr == nil){
        _listArr = [NSMutableArray new];
    }
    return _listArr;
}
- (PublicView *)nullView{
    if(_nullView == nil){
        _nullView = [[PublicView alloc]initWithFrame:CGRectMake(0, (KScreen_H-KNav_H-200)/2, KScreen_W, 200)];
        _nullView.publicLabel.text = @"暂无数据";
        _nullView.hidden = YES;
        _nullView.userInteractionEnabled = NO;
           UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:_nullView];
    }
    return _nullView;
}
-(void)showTextViewNavViewTo1{
    NSMutableArray * showTextViewNavViewNameArrTo1 = [NSMutableArray new];
    UIView * showTextViewNavViewViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewNavViewViewTo1.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:showTextViewNavViewViewTo1];
    UILabel * showTextViewNavViewLabelTo1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger showTextViewNavViewNumberTo1 = arc4random_uniform(20);
    NSLog(@"：%ld", (long)showTextViewNavViewNumberTo1);
    showTextViewNavViewLabelTo1.text = [NSString stringWithFormat:@"%ld",(long)showTextViewNavViewNumberTo1];
    [showTextViewNavViewLabelTo1 addSubview:showTextViewNavViewLabelTo1];
    
    UIImageView * showTextViewNavViewLabelTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [showTextViewNavViewViewTo1 addSubview:showTextViewNavViewLabelTo2];
    
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = NSLocalizedString(@"反馈回复", nil);
    [self.huiTable registerNib:[UINib nibWithNibName:@"DJFeedbackListCell" bundle:nil] forCellReuseIdentifier:@"DJFeedbackListCell"];
    self.huiTable.delegate = self;
    self.huiTable.dataSource = self;
    KWeakSelf
    self.huiTable.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        weakSelf.page ++;
        [weakSelf requestFeedbackList];
    }];
    self.huiTable.mj_header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
        weakSelf.page = 0;
        if (weakSelf.huiTable.mj_footer.state == MJRefreshStateNoMoreData) {
            [weakSelf.huiTable.mj_footer resetNoMoreData];
        }
        [weakSelf requestFeedbackList];
    }];
    [SVProgressHUDTool showWithStatus:nil];
    
    UIView * QZTestTo6 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    QZTestTo6.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:QZTestTo6];
    UILabel * QZTestTo7 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger  QZTestTo8 = arc4random_uniform(20);
    NSLog(@"随机数：%ld", (long) QZTestTo8);
    QZTestTo7.text = [NSString stringWithFormat:@"%ld",(long)QZTestTo8];
    [QZTestTo6 addSubview:QZTestTo7];
    
    UIButton * QZTestTo12 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    NSString * QZTestTo13 = @"agadsgads";
    [QZTestTo12 setTitle:QZTestTo13 forState:UIControlStateNormal];
    [self requestFeedbackList];
    
    
    UILabel * keyLabel = [[UILabel alloc] init];
    keyLabel.textColor = [UIColor grayColor];
    keyLabel.text = @"key";
    keyLabel.textAlignment = NSTextAlignmentCenter;
       UILabel * oldshowSSSSTip5 = [[UILabel alloc]init];
    oldshowSSSSTip5.clipsToBounds = YES;
    oldshowSSSSTip5.text = @"kass显示区";
    oldshowSSSSTip5.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip5.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip5.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip5.hidden = YES;
    [self.view addSubview:oldshowSSSSTip5];
    [self.view addSubview:keyLabel];
    
    UILabel * valueLabel = [[UILabel alloc] init];
    valueLabel.textColor = [UIColor grayColor];
    valueLabel.text = @"value";
    valueLabel.textAlignment = NSTextAlignmentCenter;
       UILabel * oldshowSSSSTip6 = [[UILabel alloc]init];
    oldshowSSSSTip6.clipsToBounds = YES;
    oldshowSSSSTip6.text = @"kass显示区";
    oldshowSSSSTip6.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip6.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip6.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip6.hidden = YES;
    [self.view addSubview:oldshowSSSSTip6];
    [self.view addSubview:valueLabel];
    
    UITextView * keyTextView1 = [[UITextView alloc] init];
    keyTextView1.backgroundColor = [UIColor whiteColor];
    keyTextView1.font = [UIFont systemFontOfSize:17];
    keyTextView1.layer.borderColor = [UIColor grayColor].CGColor;
    keyTextView1.layer.borderWidth = 1.0f;
    keyTextView1.layer.cornerRadius = 6.0f;
       UILabel * oldshowSSSSTip9 = [[UILabel alloc]init];
    oldshowSSSSTip9.clipsToBounds = YES;
    oldshowSSSSTip9.text = @"kass显示区";
    oldshowSSSSTip9.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip9.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip9.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip9.hidden = YES;
    [self.view addSubview:oldshowSSSSTip9];
    [self.view addSubview:keyTextView1];
    
    UITextView * valueTextView1 = [[UITextView alloc] init];
    valueTextView1.backgroundColor = [UIColor whiteColor];
    valueTextView1.font = [UIFont systemFontOfSize:17];
    valueTextView1.layer.borderColor = [UIColor grayColor].CGColor;
    valueTextView1.layer.borderWidth = 1.0f;
    valueTextView1.layer.cornerRadius = 6.0f;
       UILabel * oldshowSSSSTip7 = [[UILabel alloc]init];
    oldshowSSSSTip7.clipsToBounds = YES;
    oldshowSSSSTip7.text = @"kass显示区";
    oldshowSSSSTip7.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip7.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip7.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip7.hidden = YES;
    [self.view addSubview:oldshowSSSSTip7];
    [self.view addSubview:valueTextView1];
    
    UITextView * keyTextView2 = [[UITextView alloc] init];
    keyTextView2.backgroundColor = [UIColor whiteColor];
    keyTextView2.font = [UIFont systemFontOfSize:17];
    keyTextView2.layer.borderColor = [UIColor grayColor].CGColor;
    keyTextView2.layer.borderWidth = 1.0f;
    keyTextView2.layer.cornerRadius = 6.0f;
       UILabel * oldshowSSSSTip8 = [[UILabel alloc]init];
    oldshowSSSSTip8.clipsToBounds = YES;
    oldshowSSSSTip8.text = @"kass显示区";
    oldshowSSSSTip8.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip8.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip8.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip8.hidden = YES;
    [self.view addSubview:oldshowSSSSTip8];
    [self.view addSubview:keyTextView2];
    
    [CSJADLoading share].BannerAdsLoadFish = ^(id  _Nullable bannerView) {
        if(weakSelf.adView && bannerView != nil){
            [weakSelf.adView addSubview:bannerView];
            weakSelf.adHeight.constant = 45;
            [bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(weakSelf.adView);
            }];
            [UIView animateWithDuration:0.3 animations:^{
                [weakSelf.view layoutIfNeeded];
            }];
        }
        
    };
    [CSJADLoading ADBannerAdRequest:self];
}
- (void)requestFeedbackList{
    KMutableDic(sendDic)
    KWeakSelf
    sendDic[@"page"] = @(self.page);
    [YBNetBase feedBackHistoryListRequest:sendDic successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
        [SVProgressHUDTool dismiss];
        if(code == 200){
            if(!weakSelf.page){
                [weakSelf.listArr removeAllObjects];
            }
            NSArray *list = data[@"list"];
            [weakSelf.listArr addObjectsFromArray:list];
            [weakSelf.huiTable reloadData];
            if([weakSelf.huiTable.mj_header isRefreshing]){
                [weakSelf.huiTable.mj_header endRefreshing];
            }else if ([weakSelf.huiTable.mj_footer isRefreshing]){
                if([list count] == 0){
                    [weakSelf.huiTable.mj_footer endRefreshingWithNoMoreData];
                }else{
                    [weakSelf.huiTable.mj_footer endRefreshing];
                }
            }else{
                if(weakSelf.listArr.count == 0){
                    weakSelf.nullView.hidden = NO;
                    weakSelf.huiTable.mj_footer.hidden = YES;
                }else{
                    weakSelf.nullView.hidden = YES;
                    weakSelf.huiTable.mj_footer.hidden = NO;
                }
            }
        }else{
            [YBMsgPop showPop:msg];
        }
    }];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.listArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewAutomaticDimension;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DJFeedbackListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"DJFeedbackListCell"];
    [cell showConfig:self.listArr[indexPath.row]];
    return cell;
}
- (IBAction)onTap1:(UIGestureRecognizer *)recognizer {
    QYDetailViewController *vc = [[QYDetailViewController alloc] init];
    vc.index = 1;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)onTap2:(UIGestureRecognizer *)recognizer {
    QYDetailViewController *vc = [[QYDetailViewController alloc] init];
    vc.index = 2;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)onTap3:(UIGestureRecognizer *)recognizer {
    QYDetailViewController *vc = [[QYDetailViewController alloc] init];
    vc.index = 3;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)onTap4:(UIGestureRecognizer *)recognizer {
    QYDetailViewController *vc = [[QYDetailViewController alloc] init];
    vc.index = 4;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)showToast:(NSString *)toast {
    UIViewController *topVC = [UIApplication sharedApplication].keyWindow.rootViewController;
    if (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }

}

- (UIImage *)getImageInBundle:(NSString *)imageName {
    NSString *name = [@"QYCustomResource.bundle" stringByAppendingPathComponent:imageName];
    UIImage *image = [UIImage imageNamed:name];
    if (!image) {
        name = [@"QYResource.bundle" stringByAppendingPathComponent:imageName];
        image = [UIImage imageNamed:name];
    }
    return image;
}
-(NSNumber *)getQZNumberStr:(NSString *)str{
    int scannedNumber;
    NSScanner *scanner = [NSScanner scannerWithString:str];
    [scanner scanInt:&scannedNumber];
    NSNumber *number = [NSNumber numberWithLongLong: scannedNumber];
    return number;
}
@end
